﻿using System;
using System.Windows.Forms;

namespace Game.Client.ChineseChess
{
    static class ControlExtension
    {
        public static void DoActionCrossThreads(this Control control, Action act)
        {
            if (control.IsHandleCreated)
            {
                control.Invoke(new MethodInvoker(act));
            }
            else
            {
                act();
            }
        }

        public static void FlashWindow(this Form form)
        {
            FlashWindow(form.Handle, true);
        }

        [System.Runtime.InteropServices.DllImport("user32.dll", EntryPoint = "FlashWindow")]
        public static extern bool FlashWindow(IntPtr hWnd, bool bInvert);
    }
}
